//
//  QDPayTypeTableViewCell.swift
//  QDMetroClient
//
//  Created by YueWen on 2019/2/28.
//  Copyright © 2019 YueWen. All rights reserved.
//

import UIKit

/// 支付类型cell
final class QDPayTypeTableViewCell: NWTableViewCell {

    /// 背景图层
    let backImageView = UIImageView()
    /// 放置支付方式图标
    let headerImageView = UIImageView()
    /// 显示微信支付
    let titleLabel = UILabel()
    /// 优惠信息
    let subtitleLabel = UILabel()
    /// 箭头图标
    let arrowImageView = UIImageView()
    /// 状态背景图
    let statusImageView = UIImageView()
    /// 状态文字
    let statusLabel = UILabel()
    
    override func buildView() {
        super.buildView()
        
        backImageView.image = "pt_background".namedImage?.resizableImage(withCapInsets: UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20))
        
        headerImageView.backgroundColor = .white
        arrowImageView.image = "pt_arrow_right".namedImage
        statusImageView.backgroundColor = .white
        
        titleLabel.font = Font.light.font(size: 16)
        titleLabel.textColor = QDColors.black
        titleLabel.text = "支付宝支付"
        
        subtitleLabel.font = Font.regular.font(size: 12)
        subtitleLabel.textColor = #colorLiteral(red: 0.7019607843, green: 0.7019607843, blue: 0.7019607843, alpha: 1)
        subtitleLabel.text = "银联支付5折起"
        
        statusLabel.font = Font.medium.font(size: 10)
        statusLabel.textColor = .white
        statusLabel.textAlignment = .center
        statusLabel.text = "解绑中"
        
        contentView.addSubview(backImageView)
        contentView.addSubview(headerImageView)
        contentView.addSubview(titleLabel)
        contentView.addSubview(subtitleLabel)
        contentView.addSubview(arrowImageView)
        contentView.addSubview(statusImageView)
        statusImageView.addSubview(statusLabel)
        
        backImageView.snp.makeConstraints { (make) in
            make.top.equalToSuperview()
            make.bottom.equalToSuperview().inset(6)
            make.left.equalToSuperview().offset(13)
            make.right.equalToSuperview().inset(13)
        }
        
        headerImageView.snp.makeConstraints { (make) in
            make.width.height.equalTo(24)
            make.left.equalToSuperview().offset(40)
            make.top.equalToSuperview().offset(30)
        }
        
        titleLabel.snp.makeConstraints { (make) in
            make.centerY.equalTo(headerImageView)
            make.left.equalTo(headerImageView.snp.right).offset(15)
            make.height.equalTo(22)
        }
        
        
        arrowImageView.snp.makeConstraints { (make) in
            make.width.height.equalTo(16)
            make.right.equalToSuperview().inset(36)
            make.centerY.equalTo(titleLabel)
        }
        
        subtitleLabel.snp.makeConstraints { (make) in
            make.right.equalToSuperview().inset(72)
            make.height.equalTo(17)
            make.centerY.equalTo(titleLabel)
        }
        
        statusImageView.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(7)
            make.right.equalToSuperview().inset(20)
            make.height.equalTo(20)
            make.width.equalTo(56)
        }
        
        statusLabel.snp.makeConstraints { (make) in
            make.edges.equalToSuperview()
        }
    }
}
